<?php

namespace app\api\controller\app;

use app\admin\model\Banner;
use app\admin\model\City;
use app\admin\model\Org;
use app\admin\model\OrgIndexNotice;
use app\admin\model\OrgNotice;
use app\admin\model\Roomclean;
use app\admin\model\Shop;
use app\admin\model\Shopdevice;
use app\admin\model\Shopmno;
use app\admin\model\Shoporder;
use app\admin\model\Shoporderprofit;
use app\admin\model\Shoproom;
use app\admin\model\Shoproombook;
use app\admin\model\Userbalance;
use app\admin\model\Userorderprofit;
use app\admin\model\Usertuan;
use app\api\service\DeviceService;
use app\api\service\MtService;
use app\api\service\MtUtil;
use app\api\service\VbillService;
use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use fast\Http;
use fast\Random;
use think\Config;
use think\Validate;

/**
 */
class Test extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = '*';

    public function _initialize()
    {
        parent::_initialize();

    }

    public function info()
    {

        $device_sn = $this->request->param('device_sn');
        if(!$device_sn) $this->error("请输入设备编号");

        $url = "http://qhy.51fxyf.com/api/app/index/factory";
        $req = array();
        $req['device_sn'] = $device_sn;
        $result = Http::post($url,$req);

        error_log("===result===".json_encode($result));
        $result = json_decode($result,true);
        $this->success('',$result['data']);
    }


    public function testCmd()
    {
        $device_sn = $this->request->param('device_sn');
        $sec = $this->request->param('sec');
        $sn = $this->request->param('sn');
        $shopDeviceModel = new Shopdevice();
        $device = $shopDeviceModel->where('device_sn',$device_sn)->find();

        //if($device['shop_id'] != -1) $this->error("此设备已绑定不允许测试");

        $req = array();
        $req['sec'] =$sec;
        $req['orderNo'] = getOrderSn();
        $req['sn'] = $sn;
        $req['voice'] = "";


        //error_log("===工厂测试==".json_encode($req));
        $ret = http_post_json($this->openCmdUrl, json_encode($req));
        $ret = json_decode($ret, true);
        if ($ret['code'] == 0) {
            $msg = "正在打开中";
        }

        $this->success('已发送指令');
    }

}
